package cn.itcast.direct;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;


@Component
public class InfoConsumer {

    /**
     * 监听消息的方法
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "${direct.info.queue}"), // 队列
            key = {"info"}, // 路由键
            exchange = @Exchange(name = "${log.direct}", type = ExchangeTypes.DIRECT))) // 交换机
    public void handlerMesage(String msg){
        System.out.println("info--->接受到的消息是：" + msg);
    }
}
